  var easymana_tableId = "t_table"; //table grid ID
  var easymana_formName = "";
  var easymana_form = null;
  var cur_row = -1;
  var cur_row_tr = null;

  function setTableId(tid){
  	easymana_tableId = tid;
  }
  function setFormName(fn){
  	easymana_formName = fn;
  	easymana_form = eval("document." + easymana_formName);
  }
  //------------表单操作-----------------//
  function toEdit(did){
  	eval("easymana_form.action = document." + easymana_formName + ".action + " + "'?action=edit';");
	easymana_form.id.value = did;
	easymana_form.submit();
  }
  function toAdd(){
	eval("easymana_form.action = document." + easymana_formName + ".action + " + "'?action=add';");
	easymana_form.submit();
  }
  //表单操作事件
  function operateForm(operateType){
	  if(operateType == "delete"){
	    if(cur_row == -1){
	    	alert("请选中要删除的行。");
	    	return;
	    }
	    var dt = document.getElementById(easymana_tableId).childNodes[0];
	    var idValue = eval("document.all." + easymana_formName + ".id.value");
	    if(idValue == ""){
	    	var cur_tr = dt.childNodes[cur_row];
	    	dt.removeChild(cur_tr);
	    	cur_row = cur_row - 1;
	    	cur_tr = dt.childNodes[cur_row];
	    	copy(cur_tr,true);
	    	return;
	    }
    }
    if(operateType == "delete"){
    	if(!confirm("请确认您要删除数据!")) return;
    }
	if(operateType == 'add' || operateType == 'update'){
		if(!checkForm(easymana_form)){
			return;
		}
	}
  	//eval("document." + easymana_formName + ".action = document." + easymana_formName + ".action + " + "'?action=" + operateType + "';");
  	//eval("document." + easymana_form + ".action.value = '" + operateType + "';");
  	easymana_form.action.value = operateType;
  	if(operateType == "query"){
  		eval("document." + easymana_formName + ".submit()");
  	}else{
  		alert(easymana_form.my_introduction.value);
  		$(easymana_formName).send({onComplete:operComp,encoding:'UTF-8'});
  	}
  }
  
  function operComp(request){
  	if(request == "ok"){
  		alert("保存完成");
  	}else if(request == "del"){
  		alert("删除完成");
  	}else{
  		alert(request);
  	}
  }
  
  //改变行
  function changeBack(row){
	cur_row = row.rowIndex;
	if(cur_row_tr != null){
		cur_row_tr.style.backgroundColor="#F9F8E8";
	}
	row.style.backgroundColor="#EEE999";
	cur_row_tr = row
 }
 
 //增加一条记录
 function addRecord(){
 	var dt = document.getElementById(easymana_tableId);
	var thead = null;		//表头
 	var dtbody = dt.childNodes[0];
	//确定表体
	if(dtbody.tagName == "THEAD"){
		thead = dtbody;
	}
	for(var i = 0;i<dt.childNodes.length;i++){
		var tchild = dt.childNodes[i];
		if(tchild.tagName == "TBODY"){
			dtbody = tchild;
			break;
		}
	}
	//确定表头行
	if(thead == null) thead = dtbody;
	for(var i = 0;i<dtbody.childNodes.length;i++){
		if(dtbody.childNodes[i].tagName && dtbody.childNodes[i].tagName == "TR"){
			th = dtbody.childNodes[i];
			break;
		}
	}
	//复制一行
 	var newrow = dt.rows(1).cloneNode(true);
 	for (var i=0;i<newrow.childNodes.length;i++) {
		var newtd = newrow.childNodes[i];
		var thtd = th.childNodes[i];
		if(thtd.id != undefined && thtd.id.length > 0){
			var tempid = thtd.id;
			if(tempid.indexOf("_id") != (tempid.length - 3)){
				//如果还有子节点
				if(newtd.childNodes[0].tagName){
					newtd.childNodes[0].innerHTML = "default";
				}else{
					newtd.innerHTML = "default";
				}
			}else{
				newtd.innerHTML = "";
			}
		}else{
			newtd.innerHTML = "";
		}
	}
	dtbody.appendChild(newrow);
 	newrow.style.backgroundColor="#DCDCDC";
 }

function mOvr(roww) {
	roww.style.cursor = "hand";
	if(roww != cur_row_tr){
		roww.style.backgroundColor = "#FFF8C5";
	}
}
function mOut(roww) {
	roww.style.cursor = "default";
	roww.style.backgroundColor = "#F9F8E8";
	if(cur_row_tr != null){
		cur_row_tr.style.backgroundColor = "#EEE999";
	}
}
function dispTd(id){
	var tdiv = document.getElementById(id);
	var disp = document.getElementById("display");
	disp.style.left = event.clientX;
	disp.style.top = event.clientY;
	disp.innerHTML = tdiv.innerHTML;
	disp.style.display="block";
}

function hideTd(id){
	var disp = document.getElementById("display");
	disp.innerHTML = "";
	disp.style.display="none";
}
function goPage(pi){
	document.form_jump_page.action.value = "goPage";
	document.form_jump_page.toPage.value = pi;
	document.form_jump_page.submit();
}